home *** CD-ROM | disk | FTP | other *** search
Wrap
RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++)))) RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++)))) NNNNaaaammmmeeee RWBag - Rogue Wave library class SSSSyyyynnnnooooppppssssiiiissss typedef RWBag Bag; // Smalltalk typedef . #include <rw/rwbag.h> RWBag h; DDDDeeeessssccccrrrriiiippppttttiiiioooonnnn Class RRRRWWWWBBBBaaaagggg corresponds to the Smalltalk class BBBBaaaagggg. It represents a group of unordered elements, not accessible by an external key. Duplicates are allowed. An object stored by RRRRWWWWBBBBaaaagggg must inherit abstract base class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee, with suitable definition for virtual functions hhhhaaaasssshhhh(((()))) and iiiissssEEEEqqqquuuuaaaallll(((()))) (see class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee). The function hhhhaaaasssshhhh(((()))) is used to find objects with the same hash value, then iiiissssEEEEqqqquuuuaaaallll(((()))) is used to confirm the match. Class RRRRWWWWBBBBaaaagggg is implemented by using an internal hashed dictionary (RRRRWWWWHHHHaaaasssshhhhDDDDiiiiccccttttiiiioooonnnnaaaarrrryyyy) which keeps track of the number of occurrences of an item. If an item is added to the collection that compares equal (iiiissssEEEEqqqquuuuaaaallll) to an existing item in the collection, then the count is incremented. Note that this means that only the first instance of a value is actually inserted: subsequent instances cause the occurrence count to be incremented. This behavior parallels the Smalltalk implementation of BBBBaaaagggg. Member function aaaappppppppllllyyyy(((()))) and the iterator are called repeatedly according to the count for an item. See class RRRRWWWWHHHHaaaasssshhhhTTTTaaaabbbblllleeee if you want duplicates to be stored, rather than merely counted. PPPPeeeerrrrssssiiiisssstttteeeennnncccceeee Polymorphic PPPPuuuubbbblllliiiicccc CCCCoooonnnnssssttttrrrruuuuccccttttoooorrrrssss RWBag(size_t n = RWDEFAULT_CAPACITY); Construct an empty bag with nnnn buckets. RWBag(const RWBag& b); Copy constructor. A shallow copy of bbbb will be made. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr OOOOppppeeeerrrraaaattttoooorrrrssss void ooooppppeeeerrrraaaattttoooorrrr====(const RWBag& b); PPPPaaaaggggeeee 1111 RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++)))) RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++)))) Assignment operator. A shallow copy of bbbb will be made. RWBoolean ooooppppeeeerrrraaaattttoooorrrr========(const RWBag& b) const; Returns TTTTRRRRUUUUEEEE if self and bag bbbb have the same number of total entries and if for every key in self there is a corresponding key in bbbb which iiiissssEEEEqqqquuuuaaaallll and which has the same number of entries. PPPPuuuubbbblllliiiicccc MMMMeeeemmmmbbbbeeeerrrr FFFFuuuunnnnccccttttiiiioooonnnnssss virtual void aaaappppppppllllyyyy(RWapplyCollectable ap, void*); Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. This function has been redefined to apply the user-supplied function pointed to by aaaapppp to each member of the collection in a generally unpredictable order. If an item has been inserted more than once (iiii....eeee...., more than one item iiiissssEEEEqqqquuuuaaaallll), then aaaappppppppllllyyyy(((()))) will be called that many times. The user-supplied function should not do anything that could change the hash value or the meaning of "iiiissssEEEEqqqquuuuaaaallll" of the items. virtual RWspace bbbbiiiinnnnaaaarrrryyyySSSSttttoooorrrreeeeSSSSiiiizzzzeeee() const; Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. virtual void cccclllleeeeaaaarrrr(); Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. virtual void cccclllleeeeaaaarrrrAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(); Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. virtual int ccccoooommmmppppaaaarrrreeeeTTTToooo(const RWCollectable* a) const; Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. virtual RWBoolean ccccoooonnnnttttaaaaiiiinnnnssss(const RWCollectable* target) const; Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. PPPPaaaaggggeeee 2222 RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++)))) RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++)))) virtual size_t eeeennnnttttrrrriiiieeeessss() const; Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. virtual RWCollectable* ffffiiiinnnndddd(const RWCollectable* target) const; Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. The first item that was inserted into the BBBBaaaagggg and which equals ttttaaaarrrrggggeeeetttt is returned or nnnniiiillll if no item is found. Hashing is used to narrow the search. virtual unsigned hhhhaaaasssshhhh() const; Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. virtual RWCollectable* iiiinnnnsssseeeerrrrtttt(RWCollectable* c); Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. Inserts the item cccc into the collection and returns it, or if an item was already in the collection that iiiissssEEEEqqqquuuuaaaallll to cccc, then returns the old item and increments its count. RWCollectable* iiiinnnnsssseeeerrrrttttWWWWiiiitttthhhhOOOOccccccccuuuurrrrrrrreeeennnncccceeeessss(RWCollectable* c,size_t n); Inserts the item cccc into the collection with count nnnn and returns it, or if an item was already in the collection that iiiissssEEEEqqqquuuuaaaallll to cccc, then returns the old item and increments its count by nnnn. virtual RWClassID iiiissssAAAA() const; Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee to return ________RRRRWWWWBBBBAAAAGGGG. virtual RWBoolean iiiissssEEEEmmmmppppttttyyyy() const; Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. virtual RWBoolean iiiissssEEEEqqqquuuuaaaallll(const RWCollectable* a) const; PPPPaaaaggggeeee 3333 RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++)))) RRRRWWWWBBBBaaaagggg((((3333CCCC++++++++)))) Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. virtual size_t ooooccccccccuuuurrrrrrrreeeennnncccceeeessssOOOOffff(const RWCollectable* target) const; Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. Returns the number of items that aaaarrrreeee eeeeqqqquuuuaaaallll ttttoooo the item pointed to by ttttaaaarrrrggggeeeetttt. virtual RWCollectable* rrrreeeemmmmoooovvvveeee(const RWCollectable* target); Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. Removes and returns the item that iiiissssEEEEqqqquuuuaaaallll to the item pointed to by ttttaaaarrrrggggeeeetttt. Returns nnnniiiillll if no item was found. virtual void rrrreeeemmmmoooovvvveeeeAAAAnnnnddddDDDDeeeessssttttrrrrooooyyyy(const RWCollectable* target); Redefined from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. Removes the item that iiiissssEEEEqqqquuuuaaaallll to the item pointed to by ttttaaaarrrrggggeeeetttt. Destroys the item as well if it is the last occurrence in the collection. void rrrreeeessssiiiizzzzeeee(size_t n = 0); Resizes the internal hash table to have nnnn buckets. The overhead for this function is the hashing of every element in the collection. If nnnn is zero, then an appropriate size will be picked automatically. virtual void rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWvistream&); virtual void rrrreeeessssttttoooorrrreeeeGGGGuuuuttttssss(RWFile&); virtual void ssssaaaavvvveeeeGGGGuuuuttttssss(RWvostream&) const; virtual void ssssaaaavvvveeeeGGGGuuuuttttssss(RWFile&) const; Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttiiiioooonnnn. RWStringID ssssttttrrrriiiinnnnggggIIIIDDDD(); (acts virtual) Inherited from class RRRRWWWWCCCCoooolllllllleeeeccccttttaaaabbbblllleeee. PPPPaaaaggggeeee 4444